package me.xue.communityhealth.repo;

import me.xue.communityhealth.model.Disease;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface DiseaseRepository {

    @Insert("INSERT INTO `disease`(name,description,abbreviate) VALUES(#{name},#{description},#{abbreviate});")
    int save(Disease disease);

    @Delete("DELETE FROM `disease` WHERE `id`=#{id}")
    int delete(@Param("id") Integer id);

    @Update("UPDATE `disease` SET name=#{name},description=#{description},abbreviate=#{abbreviate} WHERE id=#{id}")
    int update(Disease disease);

    @Select("SELECT * FROM `disease` WHERE `id`=#{id}")
    Disease findOne(Integer id);

    @Select("SELECT * FROM `disease`")
    List<Disease> findAll();

}
